package unconditional;
import java.io.IOException;
import java.util.Arrays;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;


public class UnconditionalMapper extends Mapper<LongWritable, Text, Text, Text> {

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        String line = value.toString();
        // 分割每行数据
        String[] fields = line.split(",");

        // 检查是否包含"无条件开放"
        if (Arrays.asList(fields).contains("无条件开放")) {
            // 输出前两列和"无条件开放"作为值
            context.write(new Text("unconditional_open"), new Text(fields[0] + "," + fields[1]));
        }
    }
}